package com.yhb.controller;

import com.alipay.api.domain.Car;
import com.sun.xml.bind.v2.schemagen.xmlschema.Union;
import com.yhb.channel.ChannelDispatcher;
import com.yhb.channel.FlowService;
import com.yhb.channel.exception.PayChannelDeadException;
import com.yhb.channel.exception.RemitCardUnboundException;
import com.yhb.channel.exception.TryingBindCardException;
import com.yhb.channel.exception.TryingBindCardExceptionWrapper;
import com.yhb.channel.impl.ANYPAY.AnyPayChannel;
import com.yhb.channel.impl.ANYPAY.AnyPayTXChannel;
import com.yhb.channel.impl.BJCJ.BJCJChannel;
import com.yhb.channel.impl.BJCJ.BJCJSubChannelFactory;
import com.yhb.channel.impl.SXY.SXYChannel;
import com.yhb.channel.model.ChannelBalance;
import com.yhb.channel.model.SubChannelInfo;
import com.yhb.channel.model.TryPayPayload;
import com.yhb.channel.utils.ChannelJSONUtil;
import com.yhb.model.Card;
import com.yhb.model.MQMessage;
import com.yhb.model.TestMQModel;
import com.yhb.model.User;
import com.yhb.model.mq.TimeRangeParam;
import com.yhb.service.MQService;
import com.yhb.service.ScheduledService;
import com.yhb.service.TestService;
import com.yhb.service.UserService;
import com.yhb.third.leshua.LeShuaService;
import com.yhb.model.mq.SumUpParam;
import com.yhb.service.*;
import com.yhb.utils.DateUtils;
import com.yhb.yinsheng.UnionPayService;
import lombok.extern.log4j.Log4j;
import lombok.var;
import me.edzh.spring.bootstrap.annotations.CurrentUser;
import me.edzh.spring.bootstrap.annotations.EncryptedRequestBody;
import me.edzh.spring.bootstrap.annotations.NeedAuth;
import me.edzh.spring.bootstrap.annotations.SignedRequestBody;
import me.edzh.spring.bootstrap.model.HashMapWrapper;
import me.edzh.spring.bootstrap.model.Response;
import org.apache.http.util.TextUtils;
import org.jetbrains.annotations.NotNull;
import me.edzh.spring.bootstrap.service.PushNotificationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;

import java.util.*;
import java.math.BigDecimal;

@RestController
@RequestMapping("/test")
@Log4j
public class TestController {

    @Value("${aliyun.mq.mode}")
    private String currentType;

    @Qualifier("msgListener")
    @Autowired
    private MQService mqService;

    @Autowired
    private FlowService flowService;

    @Autowired
    private TestService testService;

    @Autowired
    private ChannelDispatcher channelDispatcher;

    @Autowired
    private ScheduledService scheduledService;

    @Autowired
    private UserService userService;

    @Autowired
    private TradeService tradeService;

    @Autowired
    private SplittingService splittingService;

    @Autowired
    private LeShuaService leShuaService;

    @Autowired
    private PushNotificationService pushNotificationService;


    @Autowired
    private UnionPayService unionPayService;

    @Autowired
    private MPosService mPosService;

    @Autowired
    private CpsService cpsService;

    @Autowired
    private BJCJSubChannelFactory bjcjSubChannelFactory;

    @Autowired
    private AnyPayTXChannel anyPayTXChannel;

    @GetMapping("/calActivate")
    public Response calActivate() {
        String monthString = DateUtils.getLastMonthString();
        List<String> rootUsers = userService.getRootUserIds();
        for (var u : rootUsers) {
            MQMessage mqMessage = MQMessage.builder()
                    .type(MQMessage.T_CALC_MONTHLY_ACTIVATE_BONUS)
                    .content(SumUpParam.builder()
                            .monthString(monthString)
                            .userId(u)
                            .build())
                    .build();

            mqService.sendMsg(mqMessage);
        }

        return Response.ok();
    }

    @PostMapping("/anyPay/userSignUp")
    public Response<String> anyPayUserSignUp(@NotNull @CurrentUser User user,
                                     @NotNull @EncryptedRequestBody HashMapWrapper map) {
        var userId = user.getId();
        var province = "广东";
        var city = "深圳市";
        var area = "南山区";
        var payRate = "0.05";
        Card card = Card.builder()
                .id("testCardId")
                .bankName("中国银行")
                .number("6216632000000132441")
                .phoneNumber("15989476248")
                .type(Card.Type.DEBIT)
                .province("广东省")
                .city("深圳市")
                .district("南山区")
                .build();
        anyPayTXChannel.userSignUp(userId, province, city, area, card, payRate);
        return Response.ok("ok");
    }

    @PostMapping("/anyPay/bindCard")
    public Response<String> anyPayBindCard(@NotNull @CurrentUser User user,
                                             @NotNull @EncryptedRequestBody HashMapWrapper map) {
        var userId = user.getId();
        Card card = Card.builder()
                .province("广东省")
                .city("深圳市")
                .district("南山区")
                .id("testCardId2")
                .bankName("中信银行")
                .number("6226880207357930")
                .phoneNumber("15989476248")
                .type(Card.Type.CREDIT)
                .validation("0923")
                .cvv2("566")
                .build();
        var uuid = anyPayTXChannel.bindCard(userId, card, "");
        return Response.ok(uuid);
    }

    @PostMapping("/anyPay/bindCardConfirm")
    public Response<String> anyPayBindCardConfirm(@NotNull @CurrentUser User user,
                                           @NotNull @EncryptedRequestBody HashMapWrapper map) {
        var cardId = anyPayTXChannel.bindCardConfirm(
                (String) map.getMap().get("smsCode"),
                user.getId(),
                (String) map.getMap().get("uuid")
        );
        return Response.ok(cardId);
    }

    @PostMapping("/anyPay/pay")
    public Response<String> anyPayPay(@NotNull @CurrentUser User user,
                                           @NotNull @EncryptedRequestBody HashMapWrapper map) {
        anyPayTXChannel.updatePayRate(user.getId(), "0.005");
        var userId = user.getId();
        Card remitCard = Card.builder()
                .province("广东省")
                .city("深圳市")
                .district("南山区")
                .id("testCardId")
                .bankName("中国银行")
                .number("6216632000000132441")
                .phoneNumber("15989476248")
                .type(Card.Type.DEBIT)
                .build();
        Card payCard = Card.builder()
                .province("广东省")
                .city("深圳市")
                .district("南山区")
                .id("testCardId2")
                .bankName("中信银行")
                .number("6226880207357930")
                .phoneNumber("15989476248")
                .type(Card.Type.CREDIT)
                .validation("0923")
                .cvv2("566")
                .build();
        String flowId = null;
        try {
            anyPayTXChannel.pay(
                    userId, payCard, remitCard,
                    BigDecimal.valueOf(23), BigDecimal.valueOf(12 * 0.005),
                    "183.17.230.8", "广东", "深圳", "南山区");
        } catch (PayChannelDeadException ignore) {
        } catch (TryingBindCardException e) {
            return Response.ok(ChannelJSONUtil.toJson(
//                    new HashMap<String, String>() {{
//                        put("payload", e.getTryPayPayloadJson());
//                    }}
                    e
            ));
        }
        return Response.ok("");
    }

    @PostMapping("/anyPay/verifyPay")
    public Response<String> anyPayVerifyPay(@NotNull @CurrentUser User user,
                                      @NotNull @EncryptedRequestBody HashMapWrapper map)
            throws TryingBindCardException, PayChannelDeadException {
        var _map = map.getMap();
        anyPayTXChannel.verifyPay(user.getId(), (String) _map.get("smsCode"), ChannelJSONUtil.parseJson(
                (String) _map.get("payload"),
                TryPayPayload.class
        ));
        return Response.ok("");
    }

//    @PostMapping("/anyPay/remit")
//    public Response<String> anyPayRemit(@NotNull @CurrentUser User user,
//                                      @NotNull @EncryptedRequestBody HashMapWrapper map) {
//        var b = anyPayChannel.getBalance(user.getId());
//        var userId = user.getId();
//        Card remitCard = Card.builder()
//                .id("testCardId")
//                .bankName("中国银行")
//                .number("6216632000000132441")
//                .phoneNumber("15989476248")
//                .type(Card.Type.DEBIT)
//                .build();
//        Card payCard = Card.builder()
//                .id("testCardId2")
//                .bankName("中信银行")
//                .number("6226880207357930")
//                .phoneNumber("15989476248")
//                .type(Card.Type.CREDIT)
//                .validation("0923")
//                .cvv2("566")
//                .build();
//        String flowId = null;
//        try {
//            flowId = anyPayChannel.remit(
//                    userId, remitCard, payCard,
//                    b.getBalance().subtract(BigDecimal.valueOf(2)), BigDecimal.valueOf(2), false, null);
//        } catch (RemitCardUnboundException e) {
//            e.printStackTrace();
//        }
//        return Response.ok(flowId);
//    }

//    @PostMapping("/anyPay/getBalance")
//    public Response anyPayGetBalance(@NotNull @CurrentUser User user,
//                                      @NotNull @EncryptedRequestBody HashMapWrapper map) {
//        var b = anyPayChannel.getBalance("2772a881-4659-11ea-91fc-00163e0c8cb0");
//
//        return Response.ok(b);
//    }

//    @PostMapping("/sign")
//    public Response<Map> test(@SignedRequestBody HashMapWrapper map) {
//        log.info("sign");
//        return new Response<>(map.getMap());
//    }
//
//    @PostMapping("/rsa")
//    public Response testPost(@EncryptedRequestBody HashMapWrapper map) {
//        log.info("sign");
//        return new Response<>(map.getMap());
//    }
//
//    @GetMapping("/mqSend")
//    public Response testMq() {
//        MQMessage<TestMQModel> message = new MQMessage<>();
//        message.setType(MQMessage.T_TEST);
//        message.setContent(TestMQModel.builder().key("fufkfuckfufk").build());
//        mqService.sendMsg(message);
//
//        return Response.ok();
//    }
//
//    @GetMapping("/testAes")
//    public Response testAes() {
//        cpsService.loginCps("heiheihei");
//        return Response.ok();
//    }
////
////    @GetMapping("/sumUp")
////    public Response sumUp() {
////        scheduledService.startSumUpTradeFlows();
////
////        return Response.ok();
////    }
////
////    @GetMapping("/async")
////    public Response testAsync() {
////
////        log.info("controller");
////        testService.async();
////        return Response.ok();
////    }
//
//
    @GetMapping("/resetCertificate")
    @NeedAuth
    public Response resetCertificate(@CurrentUser User user) {
        userService.resetCertificate(user);
        return Response.ok();
    }

//
//    @GetMapping("/earnVip")
//    public Response earnVip() {
//        userService.earnVip(userService.getUserByMobilePhone("15873562563"), Integer.MAX_VALUE);
////        userService.earnVip(userService.getUserByMobilePhone("15870999188"), Integer.MAX_VALUE);
////        userService.earnPrimeVip(userService.getUserByMobilePhone("17796345799"), Integer.MAX_VALUE);
//        return Response.ok();
//
//    }
////
////    @GetMapping("/startSumUp20191130")
////    public Response startSum() {
////        MQMessage mqMessage = MQMessage.builder()
////                .type(MQMessage.T_CALC_FLOW_SUM_UP)
////                .content(SumUpParam.builder()
////                        .dateString("20191130")
////                        .monthString("201911")
////                        .userId("10e9baf7-19ca-11ea-b54a-00163e0c8cb0")
////                        .build())
////                .build();
////
////        mqService.sendMsg(mqMessage);
////        return Response.ok();
////    }
////
////    @GetMapping("/earnVip")
////    public Response earnVip() {
////        if ("local".equals(currentType)) {
////            userService.earnVip(userService.getUser("10e9baf7-19ca-11ea-b54a-00163e0c8cb0"), Integer.MAX_VALUE);
////            userService.earnVip(userService.getUser("10e9d1d6-19ca-11ea-b54a-00163e0c8cb0"), Integer.MAX_VALUE);
////            userService.earnVip(userService.getUser("10ea603c-19ca-11ea-b54a-00163e0c8cb0"), Integer.MAX_VALUE);
////            userService.earnVip(userService.getUser("10ea8cde-19ca-11ea-b54a-00163e0c8cb0"), Integer.MAX_VALUE);
////            userService.earnVip(userService.getUser("10ead4bb-19ca-11ea-b54a-00163e0c8cb0"), Integer.MAX_VALUE);
////            userService.earnVip(userService.getUser("10ead841-19ca-11ea-b54a-00163e0c8cb0"), Integer.MAX_VALUE);
////        }
////        return Response.ok();
////    }
////
////    @GetMapping("/startSumSplitting")
////    public Response startSumSplitting (){
////        splittingService.calculateMonthlyAmount("201911", true);
////        return Response.ok();
////    }
//
//
//
//    @GetMapping("/genUnionQR")
//    public Response genUnionQR() {
//        if ("local".equals(currentType)) {
//            unionPayService.genQRCode(userService.getUser("3508819f-0c84-11ea-8ebf-0242ac130003"), "8ffea6bc-3db7-11ea-a504-0242ac130003");
//        }
//
//        return Response.ok();
//    }
//
//    @GetMapping("/yinshengBindCard")
//    public Response yinshengBindCard() {
////        f582d560-3dac-11ea-bc66-0242ac130003
//
//        if ("local".equals(currentType)) {
//            unionPayService.bindCard("f582d560-3dac-11ea-bc66-0242ac130003", userService.getUser("3508819f-0c84-11ea-8ebf-0242ac130003"));
//        }
//
//        return Response.ok();
//    }

    @GetMapping("/startOutputReport")
    public Response startOutputReport() {
        splittingService.startOutputIncomeReport("202004");
        return Response.ok();
    }

    @GetMapping("/genSummary")
    public Response genSummary() {
        splittingService.startOutputIncomeSummaryReport("202004");
        return Response.ok();
    }
//
//    @GetMapping("/pos/syncMerchant")
//    public Response syncPosMerchant() {
//        mPosService.syncMerchantId(new Date(120, Calendar.FEBRUARY, 22), new Date(120, Calendar.FEBRUARY, 28, 23, 59, 59));
//        return Response.ok();
//    }
//
//    @GetMapping("/pos/syncMerchant/{fromDate}/{endDate}")
//    public Response syncPosMerchantDateRange(@PathVariable("fromDate")String fromDate, @PathVariable("endDate")String endDate) {
//        mPosService.syncMerchantId(new Date(120, Calendar.JANUARY, Integer.parseInt(fromDate)), new Date(120, Calendar.JANUARY, Integer.parseInt(endDate), 23, 59, 59));
//        return Response.ok();
//    }
//
////    @GetMapping("/calMd5")
////    public Response calculateMd5() {
////        userService.updateMd5();
////        return Response.ok();
////    }
//
//    @GetMapping("/push")
//    public Response push() {
//        pushNotificationService.send("e2972827-0c81-11ea-b54a-00163e0c8cb0", "test", null, PushNotificationService.PUSH_ANDROID | PushNotificationService.PUSH_IOS);
//        return Response.ok();
//    }
//
//    @GetMapping("/queryLeshuaFlow")
//    public Response queryLeshuaFlow() {
//        mPosService.syncOrders(new Date(119, Calendar.DECEMBER, 17), new Date(119, Calendar.DECEMBER, 17, 23, 59, 59));
//
//        return Response.ok();
//    }
//
//    @GetMapping("/union/queryYinshengBalance")
//    public Response queryYinshengBalance() {
//        unionPayService.queryBalance(User.builder().id("ce178ae3-3910-11ea-b54a-00163e0c8cb0").build());
//
//        return Response.ok();
//    }
//
//    @GetMapping("/union/queryUserCode/{id}")
//    public Response queryUserCode(@PathVariable("id")String id) {
//        unionPayService.queryUserCode(id);
//
//        return Response.ok();
//    }
//
//    @GetMapping("/union/queryStatus")
//    public Response queryUnionStatus() {
//        unionPayService.queryOrder("bf46ac80-48ef-11ea-91fc-00163e0c8cb0");
//
//        return Response.ok();
//    }
////
////    @GetMapping("/sumFollowers")
////    public Response sumUpFollowers() {
//////        scheduledService.startSumUpActiveUsers();
////        var c = DateUtils.getYesterday();
////        var endTime = c.getTime();
////        c.add(Calendar.DAY_OF_MONTH, -60);
////        DateUtils.setFirstTimeOfDay(c);
////        var startTime = c.getTime();
////
////        List<String> rootUsers = userService.getRootUserIds();
////        for (String userId : rootUsers) {
////            MQMessage mqMessage = MQMessage.builder()
////                    .type(MQMessage.T_CALC_ACTIVE_USER)
////                    .content(TimeRangeParam.builder()
////                            .userId(userId)
////                            .startTime(startTime)
////                            .endTime(endTime)
////                            .build())
////                    .build();
////
////            mqService.sendMsg(mqMessage);
////        }
////        return Response.ok();
////    }
//
//
////    @PostMapping("/mapleTest")
////    public Response<String> mapleTest() {
////        ExecutionFlow executionFlow = ExecutionFlow
////                .builder()
////                .userId(UUID.randomUUID().toString())
////                .vipType("vip")
////                .type(ExecutionFlow.Type.PAY)
////                .channelType(ChannelFactory.SXY)
////                .amount(BigDecimal.valueOf(3))
////                .extendInfo("233333")
////                .cardId(UUID.randomUUID().toString())
////                .requestId(UUID.randomUUID().toString())
////                .commission(BigDecimal.valueOf(2))
////                .remitFee(BigDecimal.valueOf(1))
////                .build();
////        String id = flowUtil.add(executionFlow);
////        return Response.ok(id);
////    }
////
////    @PostMapping("/mapleTest2")
////    public Response mapleTest2(@EncryptedRequestBody HashMapWrapper map) {
////        String flowId = (String) map.getMap().get("id");
////        Date date = new Date();
////        sxyChannel.retryRemit(flowId, date);
////        return Response.ok();
////    }
//
////    @PostMapping("/bjcj/bind")
////    @NeedAuth
////    public Response<String> bindBJCJCard(@NotNull @CurrentUser User user, @NotNull @EncryptedRequestBody HashMapWrapper map) {
////        BJCJChannel bjcjChannel = bjcjSubChannelFactory.getSubChannel("LARGE_CHANNEL17");
////        String smsCode = (String) map.getMap().get("smsCode");
////        String uuid1 = (String) map.getMap().get("uuid");
////        if (TextUtils.isEmpty(smsCode)) {
////            Card payCard = Card.builder()
////                    .bankName("中信银行")
////                    .subBankName("中信银行南山分行")
////                    .phoneNumber("15989476248")
////                    .province("广东省")
////                    .city("深圳市")
////                    .district("南山区")
////                    .number("6226880207357930")
////                    .type(Card.Type.CREDIT)
////                    .cvv2("566")
////                    .validation("0923")
////                    .id(UUID.randomUUID().toString())
////                    .build();
////            String uuid = bjcjChannel.tryBindCard(user.getId(), payCard, "183.17.229.199", "0.32");
////            return Response.ok(uuid);
////        } else {
////            String cardId = bjcjChannel.bindCardConfirm(smsCode, user.getId(), uuid1);
////            return Response.ok(cardId);
////        }
////    }
//
//    @PostMapping("/bjcj/pay")
//    @NeedAuth
//    public Response<String> payBJCJ(@NotNull @CurrentUser User user,
//                                       @NotNull @EncryptedRequestBody HashMapWrapper map) {
//        BJCJChannel bjcjChannel = bjcjSubChannelFactory.getSubChannel("LARGE_CHANNEL17");
//        bjcjChannel.updatePayRate(user.getId(), "0.47");
//        Card payCard = Card.builder()
//                .bankName("中信银行")
//                .subBankName("中信银行南山分行")
//                .phoneNumber("15989476248")
//                .province("广东省")
//                .city("深圳市")
//                .district("南山区")
//                .number("6226880207357930")
//                .type(Card.Type.CREDIT)
//                .cvv2("566")
//                .validation("0923")
//                .id("7e75c54b-7904-4c84-852c-3862bb738665")
//                .build();
////        Card remitCard = Card.builder()
////                .id("6216632000000132441")
////                .number("6216632000000132441")
////                .bankName("中国银行")
////                .subBankName("中国银行南山支行")
////                .phoneNumber("15989476248")
////                .province("广东省")
////                .city("深圳市")
////                .district("南山区")
////                .type(Card.Type.DEBIT)
////                .build();
//        Card remitCard = Card.builder()
//                .number("6217234000002798892")
//                .bankName("中国工商银行")
//                .subBankName("工商银行南山支行")
//                .phoneNumber("15989476248")
//                .province("广东省")
//                .city("深圳市")
//                .district("南山区")
//                .type(Card.Type.DEBIT)
//                .build();
//        String flowId = "";
////        try {
////            flowId = bjcjChannel.tryPay(user.getId(), payCard, remitCard,
////                    BigDecimal.valueOf(15), BigDecimal.valueOf(0.5), "183.17.229.199", "0.47");
////        } catch (TryingBindCardException | PayChannelDeadException e) {
////            log.error(e);
////        }
//        return Response.ok(flowId);
//    }
//
//    @PostMapping("/bjcj/remit")
//    @NeedAuth
//    public Response<String> remitBJCJ(@NotNull @CurrentUser User user,
//                                       @NotNull @EncryptedRequestBody HashMapWrapper map) {
//        BJCJChannel bjcjChannel = bjcjSubChannelFactory.getSubChannel("LARGE_CHANNEL17");
//        Card remitCard = Card.builder()
//                .number("6214867843552333")
//                .bankName("招商银行")
//                .subBankName("招商银行南山支行")
//                .phoneNumber("15989476248")
//                .province("广东省")
//                .city("深圳市")
//                .district("南山区")
//                .type(Card.Type.DEBIT)
//                .build();
//        String flowId = "";
////        flowId = bjcjChannel.remit(user.getId(), remitCard, BigDecimal.valueOf(29.53), BigDecimal.valueOf(0.3));
//        return Response.ok(flowId);
//    }
//
////    @PostMapping("/channel/dispatcher/tryPay")
////    public Response<String> dispatcherTester(@NotNull @CurrentUser User user) {
////        Card payCard = Card.builder()
////                .bankName("中信银行")
////                .subBankName("中信银行深圳南山支行")
////                .number("6226880207357930")
////                .phoneNumber("15989476248")
////                .id("6226880207357930-id")
////                .validation("0923")
////                .cvv2("566")
////                .type(Card.Type.CREDIT)
////                .district("南山区")
////                .city("深圳市")
////                .province("广东省")
////                .build();
////        Card remitCard = Card.builder()
////                .bankName("招商银行")
////                .subBankName("招商银行深圳南山支行")
////                .number("6214867843552333")
////                .phoneNumber("15989476248")
////                .id("6214867843552333-id")
////                .type(Card.Type.DEBIT)
////                .district("南山区")
////                .city("深圳市")
////                .province("广东省")
////                .build();
////        BigDecimal amount = BigDecimal.valueOf(10L);
////        String userId = user.getId();
////        SubChannelInfo[] channelInfoList = channelDispatcher.getChannelInfoList(payCard, remitCard, amount);
////        try {
////            channelDispatcher.pollingTryPay(userId, payCard,
////                    remitCard, amount, BigDecimal.valueOf(1L), "0.47", "1.1.1.1");
////        } catch (TryingBindCardExceptionWrapper e) {
////            e.printStackTrace();
////        }
////        return  Response.ok(ChannelJSONUtil.toJson(channelInfoList));
////    }
////
////    @PostMapping("/channel/dispatcher/verifyPay")
////    public Response<String> dispatcherTester2(@NotNull @CurrentUser User user,
////                                              @NotNull @EncryptedRequestBody HashMapWrapper map) {
////        try {
////            String id = channelDispatcher.verifyPay(user.getId(),
////                    (String) map.getMap().get("token"), (String) map.getMap().get("smsCode"));
////            return Response.ok(id);
////        } catch (TryingBindCardExceptionWrapper e) {
////            e.printStackTrace();
////        }
////        return Response.ok("");
////    }
////
////    @PostMapping("/channel/dispatcher/tick")
////    public Response dispatcherTester3() {
////        channelDispatcher.triggerAllChannelTicks();
////        return Response.ok();
////    }
//
//    @PostMapping("/channel/dispatcher/queryBalance")
//    public Response<List<ChannelBalance>> dispatcherTester4(@NotNull @CurrentUser User user) {
//        return Response.ok(channelDispatcher.queryUserBalance(user.getId()));
//    }
//
//    @GetMapping("/leshua/syncFlow")
//    public Response syncLeshua() {
//        // 每20分钟同步前25分钟订单, 消费侧有排重.
//        Calendar c = Calendar.getInstance();
//        c.setTime(new Date(2020 - 1900, Calendar.MARCH, 5, 9, 20, 0));
//        var endTime = c.getTime();
//        c.add(Calendar.MINUTE, -25);
//        var startTime = c.getTime();
//
//        MQMessage mqMessage = MQMessage.builder()
//                .type(MQMessage.T_SYNC_LESHUA_ORDERS)
//                .content(TimeRangeParam.builder()
//                        .startTime(startTime)
//                        .endTime(endTime)
//                        .build())
//                .build();
//
//        mqService.sendMsg(mqMessage);
//        return Response.ok();
//    }
//
//    @NeedAuth(User.A_ADMIN)
//    @GetMapping("/adminAuth")
//    public Response testAdminAuth() {
//        return Response.ok();
//    }

    @GetMapping("/giveV")
    public Response giveVip() {
        var s = Arrays.asList(
                "17796345799",
                "13074674851"
        );
        s.forEach(id -> {
            var u = userService.getUserByMobilePhone(id);
            userService.earnVip(u, Integer.MAX_VALUE);
            userService.earnPrimeVip(u, 1000 * 365);
        });

//         var s1 = Arrays.asList(
//                "ba683086-703d-11ea-b82c-f0a25be15609"
//        );
//        s1.forEach(id -> {
//            var u = userService.getUser(id);
//            userService.earnPrimeVip(u, 548);
//        });


        return Response.ok();
    }
}
